//1353. 最多可以参加的会议数目（medium):https://leetcode.cn/problems/maximum-number-of-events-that-can-be-attended/description/
 bool cmp(const vector<int>& a, const vector<int>& b) 
{
    // 按起点递增排序
    return a[0] < b[0];
}
class Solution 
{
public:
    int eraseOverlapIntervals(vector<vector<int>>& intervals) 
    {
        if (intervals.size() == 0) 
        {
            return 0;
        }
        // 按起点递增排序
        sort(intervals.begin(), intervals.end(), cmp);
        int end = intervals[0][0], prev = 0, count = 0;
        for (int i = 1; i < intervals.size(); i++) 
        {
            if (intervals[prev][1] > intervals[i][0]) 
            {
                if (intervals[prev][1] > intervals[i][1]) 
                {
                    // 情况2
                    prev = i;
                }
                // 情况3
                count++;
            } 
            else 
            {
                // 情况1
                prev = i;
            }
        }
        return count;
    }
};